package com.example.drainage.ui.realmdao

import com.example.drainage.util.CommonSynDao2

/**
 *  author : yanghaozhang
 *  date : 2022/8/3 11:43
 *  description :
 */
class RealmDaoController {

    companion object {
        fun savePackageBean(bean: RealmDaoPackageBean) {
            val commonSynDao = CommonSynDao2()
            commonSynDao.insertOrUpdate(bean)
        }

        fun deletePackageBean(id: String) {
            val commonSynDao = CommonSynDao2()
            commonSynDao.delete(RealmDaoPackageBean::class.java, "id", id)
        }

        fun deletePackageBean() {
            val commonSynDao = CommonSynDao2()
            commonSynDao.deleteAll(RealmDaoPackageBean::class.java)
        }

        fun deleteObjBean() {
            val commonSynDao = CommonSynDao2()
            commonSynDao.deleteAll(RealmDaoObj::class.java)
        }

        fun getPackageBean(): MutableList<RealmDaoPackageBean> {
            val commonSynDao = CommonSynDao2()
            return commonSynDao.queryAll(RealmDaoPackageBean::class.java)
        }

        fun getObjBean(): MutableList<RealmDaoObj> {
            val commonSynDao = CommonSynDao2()
            return commonSynDao.queryAll(RealmDaoObj::class.java)
        }
    }
}